class Animal {
    name: string
    age: number

    constructor(name: string, age: number) {
        this.name = name
        this.age = age
    }

    say(): void {
        console.log('动物叫');
    }
}

class Dog extends Animal {
    say(): void {
        console.log('狗叫');
    }
}

class Cat extends Animal {
    name: string

    constructor(name: string, age: number) {
        // 如果在子类中写了构造函数，在子类构造函数中必须对父类的构造函数进行调用
        super(name, age)
        this.name = name
    }

    say(): void {
        // 在类的方法中 super 表示当前类的父类
        super.say()
        console.log('猫叫');
    }
}

new Cat('小猫', 2).say();
